import request from '@/utils/request'

export function getDictTypes() {
  return request.get(`/system/dict/types`)
}

export function getDictItems(typeCode: string) {
  return request.get(`/system/dict/types/${encodeURIComponent(typeCode)}/items`)
}

export function getDictBatch(types: string[]) {
  const params = new URLSearchParams()
  types.forEach(t => params.append('types', t))
  return request.get(`/system/dict/batch?${params.toString()}`)
}

export function getDictLabel(type: string, value: string) {
  return request.get(`/system/dict/label`, { params: { type, value } })
}

export function createDictType(data: any) {
  return request.post(`/system/dict/types`, data)
}

export function updateDictType(id: string, data: any) {
  return request.put(`/system/dict/types/${id}`, data)
}

export function deleteDictType(id: string) {
  return request.delete(`/system/dict/types/${id}`)
}

export function createDictItem(data: any) {
  return request.post(`/system/dict/items`, data)
}

export function updateDictItem(id: string, data: any) {
  return request.put(`/system/dict/items/${id}`, data)
}

export function deleteDictItem(id: string) {
  return request.delete(`/system/dict/items/${id}`)
}


